popLayer={
				width:null,//设置宽度
				height:null,//设置高度
				shLeft:null,
				shTop:null,
				doWidth:null,
				doHeight:null,
		   		addLayer:function(){
					popbg={width:this.doWidth,height:this.doHeight,background:'#000',position:'absolute',
							'z-index':'2222',left:'0',top:'0',opacity:'0.5'}
					popBordera={width:this.width,height:this.height,border:'4px solid #5e5e5e',
								position:'absolute',left:'0',top:'0','z-index':'3333'}
					popBorderb={width:this.width-8,height:this.height-8,border:'4px solid #979797'};
					popCont={width:this.width-8,height:this.height-8,
								background:'#e4e4e4','text-align':'center'};
					popClose={width:'20px',height:'20px',display:'block',position:'absolute',
								left:this.width-24,top:4,'font-size':'20px','z-index':'3334',
								color:'#000','text-decoration':'none','font-family': 'SimHei', 
								background:'#b5b5b5', 'line-height':'20px','text-align':'center'}
					$('<div/>').attr('id','popBg').css(popbg).prependTo('body');
					$('<div/>').attr('id','popBordera').css(popBordera).prependTo('body');
					$('<div/>').attr('id','popBorderb').css(popBorderb).prependTo('#popBordera');
					$('<div/>').attr('id','popCont').css(popCont).prependTo('#popBorderb');
			  		$('<a/>').attr({href:'#',title:'关闭',id:'popClose'}).text('x')
								.css(popClose).prependTo('#popBordera');
					popLayer.width=$('#popBordera').outerWidth();
					popLayer.height=$('#popBordera').outerHeight();
					lefts=this.shLeft-popLayer.width /2;
					tops=this.shTop - popLayer.height/2;
					tops=tops<0?0:tops;
					$('#popBordera').css({left:lefts,top:tops});
					
					$(window).resize(function(){
						popLayer.doWidth=$(document).width();
						popLayer.doHeight=$(document).height();
		 				$('#popBg').css({width: popLayer.doWidth,height: popLayer.doHeight});
					});
		   	},
				closeLayer:function(){
				$('#popClose').click(function(){
					
					popwidth=popLayer.width;
					popheight=popLayer.height;
					s=popheight>popwidth?popheight/2:popwidth/2;
					speed=s/25;
					$popBordera=$('#popBordera');
				
					tops=0;rights= popwidth; bottoms = popheight; lefts=0;
						
					function hide(){
						ss=setTimeout(hide,20);
						if(lefts>s) {
							
							clearInterval(ss);
							$popBordera.remove();
							$('#popBg').remove();
						}
						lefts+=speed;
						tops+=speed;
						bottoms-=speed;
						rights-= speed;
						
						$popBordera.css({clip:'rect('+tops+'px '+rights+'px '+bottoms+'px '+lefts+'px)'});
						
					}
				 	setTimeout(hide,30);//	hide();
					

					return false;
				});
			},
			changeLayer:function(w,h){

					popwidth=popLayer.width;
					popheight=popLayer.height;
					w+=8;
					h+=8;
					
					if(w<=popwidth&&h<=popheight){
							flag=1;
							speedw=(popwidth-w)/30;//10   500 500   200 300
							speedh=(popheight-h)/30;//6.6
						
						
					}else if(w<=popwidth&&h>popheight){
						flag=2;
						speedw=(popwidth-w)/30;
						speedh=(h-popheight)/30;
						
						
					}else if(w>popwidth&&h<=popheight){
						flag=3;
						speedw=(w-popwidth)/30;
						speedh=(popheight-h)/30;
					}else if(w>popwidth&&h>popheight){
						flag=4;
						speedw=(w-popwidth)/30;
						speedh=(h-popheight)/30;
					}
					
					
					$popBordera=$('#popBordera');
					$popBorderb=$('#popBorderb');
					$popCont=$('#popCont');
					$popClose=$('#popClose');
					
				function change(){
					
						ss=setTimeout(change,20);
						function end(){
								popwidth=w-8;
								popheight=h-8;
								lefts=popLayer.shLeft-popwidth/2;
							 	tops=popLayer.shTop -popheight/2;	
								$popBordera.css({width:popwidth,height:popheight,left:lefts,top:tops});
								$popBorderb.css({width: popwidth-8,height: popheight-8});
								$popCont.css({width: popwidth-8,height: popheight-8});
								$popCont.find('#popImg').css({width: popwidth-8,height: popheight-8});
								$popClose.css({left: popwidth-24,top: 4});
								popLayer.width=w;popLayer.height=h;
							
						}
						if(flag==1) {
							if(popheight<=h+speedh&&w>h){
								clearInterval(ss);
								end();
								return ;
							}else if(popwidth<=w+speedw&&w<=h){
								clearInterval(ss);
								end();
								return ;
							}
							
						}else if(popheight>=h+speedh&&flag==2){
							
							clearInterval(ss);
							end();
							return ;
						}else if(popwidth>=w+speedw&&flag==3){
							clearInterval(ss);
							end();
							return ;
						}else if(popwidth>=w+speedw&&flag==4){
							clearInterval(ss);
							end();
							return ;
						}
						if(flag==1){
							popwidth-=speedw;
							popheight-=speedh;	
						}else if(flag==2){
							popwidth-=speedw;
							popheight+=speedh;	
							
						}else if(flag==3){
							popwidth+=speedw;
							popheight-=speedh;	
						}else if(flag==4){
							popwidth+=speedw;
							popheight+=speedh;	
						}		
						
						
						lefts=popLayer.shLeft-popwidth/2;
						tops=popLayer.shTop -popheight/2;
						$popBordera.css({width:popwidth,height:popheight,left:lefts,top:tops});
						$popBorderb.css({width: popwidth-8,height: popheight-8});
						$popCont.css({width: popwidth-8,height: popheight-8});
						$popCont.find('#popImg').css({width: popwidth-8,height: popheight-8});
						$popClose.css({left: popwidth-24,top: 4});

					}
			setTimeout(change,30);//	hide();
			},
			setCont: function(cont){
				$(cont).appendTo('#popCont');
				
			},
			clearCont: function(){
				$('#popCont').html('');
			},
			closeCl:function(){
				$('#popClose').click();
			},
		    init:function(w,h){
				this.doWidth=$(document).width();//+$(document).scrollLeft();
				this.doHeight=$(document).height();//+$(document).scrollTop();
				this.shLeft=$(document).scrollLeft()+$(window).width()/2;
				this.shTop=$(document).scrollTop()+$(window).height()/2;
		   		this.width=w;
				this.height=h;
				this.addLayer();
				this.closeLayer();
		
		   }
}
/**
 * popLayer.init(400,300);
 * popLayer.setCont('<b>这个是测试的</b>');
 * popLayer.changeLayer(200,500);
 */